package common

import (
	"context"

	"github.com/gogf/gf/v2/util/gconv"
)

var CommonUtil = commonUtil{}

type commonUtil struct{}

// 获取当前token中的parentId
func (a *commonUtil) GetTokenParentId(ctx context.Context) (parentId int) {
	return gconv.Int(ctx.Value("ParentId"))
}

// 获取当前token中的学校id
func (a *commonUtil) GetTokenSchoolId(ctx context.Context) (schoolId int) {
	return gconv.Int(ctx.Value("SchoolId"))
}

// 获取当前token中的openId
func (a *commonUtil) GetTokenOpenId(ctx context.Context) (openId string) {
	return gconv.String(ctx.Value("OpenId"))
}

// 获取当前token中的token
func (a *commonUtil) GetTokenTokenId(ctx context.Context) (token string) {
	return gconv.String(ctx.Value("Token"))
}
